package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount {
	private int overdraft;
	
	public CheckingAccount(int balance, int overdraft) {
		super(balance);
		this.overdraft = overdraft;
	}

	@Override
	public int getMaximumAmountToWithdraw() {
		return getBalance() + overdraft;
	}

	@Override
	public boolean withdraw(int amount) {
		if (amount >= getBalance() + overdraft) {
		    return false;
		}
		setBalance(getBalance() - amount);
		assert(overdraft >= 0);
		assert(getMaximumAmountToWithdraw() >= 0);
		return true;
	}

	@Override
	public void deposit(int amount) {
		setBalance(getBalance() + amount);
	}

}
